//
//  HLBsaeTableViewController.swift
//  MyWeiBo
//
//  Created by fannie on 16/3/20.
//  Copyright © 2016年 fannie. All rights reserved.
//

import UIKit

class HLBsaeTableViewController: UITableViewController {

    var userLogin=false
    lazy var vistorView:HLVisitorView=HLVisitorView()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        
    }

    override func loadView() {
        userLogin ? super.loadView() : setupVisitorView()
    }
    
    func setupVisitorView()->Void {
        self.view=vistorView
        
        if self is HLHomeViewController {
            vistorView.startRorationAnimation()
        }else if (self is HLMessageViewController) {
            vistorView.setupVistorInfo("visitordiscover_image_message", context: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        }else if (self is HLDiscoverViewController) {
            vistorView.setupVistorInfo("visitordiscover_image_message", context: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
        }else if (self is HLProFileViewController) {
            vistorView.setupVistorInfo("visitordiscover_image_profile", context: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }
        
        navigationItem.leftBarButtonItem=UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewRegistBtnAction")
        navigationItem.rightBarButtonItem=UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewLoginBtnAction")
        vistorView.delegate=self
    }
}

extension HLBsaeTableViewController:HLVisitorViewDelegate {
    func visitorViewRegistBtnAction() {
        print("zhuce")
    }
    func visitorViewLoginBtnAction() {
        let oauthVC=HLOAuthViewController()
        presentViewController(UINavigationController(rootViewController: oauthVC), animated: true, completion: nil)
    }
}